//
//  MyCollection.m
//  LearnObjectiveC
//
//  Created by client on 2017/9/9.
//  Copyright © 2017年 吴可高. All rights reserved.
//

#import "MyCollection.h"
#import "MyIterator.h"
@implementation MyCollection
@synthesize iterator;

- (instancetype)init
{
    self = [super init];
    if (self) {
    }
    return self;
}

-(MyIterator *)iterator
{
    if (iterator == nil) {
        iterator = [[MyIterator alloc]init];
    }
    return iterator;
}

-(void)setItems:(NSArray *)items
{
    _items = items;
}

-(NSObject *)getIndex:(int)idx
{
    if (!_items) {
        return nil;
    }
    if (idx >= _items.count) {
        return nil;
    }
    if (idx <0) {
        return nil;
    }
    return _items[idx];
}

-(int)size
{
    if (!_items) {
        return 0;
    }
    return  (int)_items.count;
}

@end
